import express from 'express';
import aiService from '../services/aiService.js';

const router = express.Router();

// 测试 AI 聊天功能
router.post('/test-chat', async (req, res) => {
  try {
    const { message } = req.body;
    
    if (!message) {
      return res.status(400).json({
        success: false,
        message: '消息不能为空'
      });
    }
    
    const result = await aiService.chat(message, 'debug_user');
    
    res.json(result);
  } catch (error) {
    console.error('Debug chat error:', error);
    res.status(500).json({
      success: false,
      message: error.message || '调试聊天服务出错',
      error: process.env.NODE_ENV === 'production' ? {} : error
    });
  }
});

export default router; 